package com.hxiaoyi.cloud.controller;

import com.hxiaoyi.cloud.entities.CommonResult;
import com.hxiaoyi.cloud.entities.Payment;
import com.hxiaoyi.cloud.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * OrderFeignController
 * @author 黄敬意
 * @date 2022-02-06 14:53
 **/
@RestController
@Slf4j
public class OrderFeignController {

    @Resource
    private PaymentFeignService paymentFeignService;
    /**
     * 调用查询端口getPayment
     * @param id
     * @return CommonResult
     */
    @GetMapping(value = "/consumer/payment/get/{id}")
    public CommonResult<Payment> getPayment(@PathVariable("id") Long id) {
        log.info("------Feign开始调用查询服务getPayment------");
        return paymentFeignService.getPaymentById(id);
    }

    /**
     * 验证feign超时,feign默认是等待1秒钟
     * @author 黄敬意
     * @date 2022/2/6 15:17
     * @return String
     **/
    @GetMapping(value = "/consumer/payment/timeout")
    public String getTimeout() {
        log.info("------Feign开始调用paymentFeignTimeout------");
        return paymentFeignService.paymentFeignTimeout();
    }
}
